package com.fp.m7.client.inject;

import net.customware.gwt.presenter.client.DefaultEventBus;
import net.customware.gwt.presenter.client.EventBus;
import net.customware.gwt.presenter.client.place.ParameterTokenFormatter;
import net.customware.gwt.presenter.client.place.PlaceManager;
import net.customware.gwt.presenter.client.place.TokenFormatter;

import com.fp.m7.client.AccountContext;
import com.fp.m7.client.place.BasicPlaceManager;
import com.fp.m7.client.presenter.AppPublicPresenter;
import com.fp.m7.client.presenter.AppSecuredPresenter;
import com.fp.m7.client.presenter.CommentPresenter;
import com.fp.m7.client.presenter.HeaderPublicPresenter;
import com.fp.m7.client.presenter.HeaderSecuredPresenter;
import com.fp.m7.client.presenter.HomePresenter;
import com.fp.m7.client.presenter.InfoPresenter;
import com.fp.m7.client.presenter.LoginPresenter;
import com.fp.m7.client.presenter.NewCommentPresenter;
import com.fp.m7.client.presenter.ProfilePresenter;
import com.fp.m7.client.presenter.RegisterPresenter;
import com.fp.m7.client.presenter.SettingsPresenter;
import com.fp.m7.client.presenter.TimelinePresenter;
import com.fp.m7.client.view.AppPublicView;
import com.fp.m7.client.view.AppSecuredView;
import com.fp.m7.client.view.CommentView;
import com.fp.m7.client.view.HeaderPublicView;
import com.fp.m7.client.view.HeaderSecuredView;
import com.fp.m7.client.view.HomeView;
import com.fp.m7.client.view.InfoView;
import com.fp.m7.client.view.LoginView;
import com.fp.m7.client.view.NewCommentView;
import com.fp.m7.client.view.ProfileView;
import com.fp.m7.client.view.RegisterView;
import com.fp.m7.client.view.SettingsView;
import com.fp.m7.client.view.TimelineView;
import com.fp.m7.shared.validator.CommentValidator;
import com.fp.m7.shared.validator.NewPasswordsValidator;
import com.fp.m7.shared.validator.RegistrationValidator;
import com.fp.m7.shared.validator.StatusAndDescriptionValidator;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Singleton;

/**
 * Description of every binding for GIN DI container.
 * 
 * @author 7
 */
public class AppGinModule extends AbstractGinModule {

    @Override
    protected void configure() {
        /** bind mvp management elements */
        bind(EventBus.class).to(DefaultEventBus.class).asEagerSingleton();

        bind(TokenFormatter.class).to(ParameterTokenFormatter.class).asEagerSingleton();

        bind(PlaceManager.class).to(BasicPlaceManager.class).asEagerSingleton();

        bind(AccountContext.class).asEagerSingleton();

        /** bind presenters to their views **/
        bind(AppPublicPresenter.Display.class).to(AppPublicView.class).in(Singleton.class);
        bind(AppSecuredPresenter.Display.class).to(AppSecuredView.class).in(Singleton.class);

        bind(HeaderPublicPresenter.Display.class).to(HeaderPublicView.class).in(Singleton.class);
        bind(HeaderSecuredPresenter.Display.class).to(HeaderSecuredView.class).in(Singleton.class);

        bind(InfoPresenter.Display.class).to(InfoView.class).in(Singleton.class);

        bind(LoginPresenter.Display.class).to(LoginView.class).in(Singleton.class);

        bind(RegisterPresenter.Display.class).to(RegisterView.class).in(Singleton.class);

        bind(ProfilePresenter.Display.class).to(ProfileView.class).in(Singleton.class);

        bind(HomePresenter.Display.class).to(HomeView.class).in(Singleton.class);

        bind(NewCommentPresenter.Display.class).to(NewCommentView.class).in(Singleton.class);

        bind(SettingsPresenter.Display.class).to(SettingsView.class).in(Singleton.class);

        bind(TimelinePresenter.Display.class).to(TimelineView.class).in(Singleton.class);

        bind(CommentPresenter.Display.class).to(CommentView.class); // not a singleton !

        /** bind user input validators */
        bind(CommentValidator.class).in(Singleton.class);
        bind(NewPasswordsValidator.class).in(Singleton.class);
        bind(RegistrationValidator.class).in(Singleton.class);
        bind(StatusAndDescriptionValidator.class).in(Singleton.class);

    }
}
